package SwordForOffer.Problem4;

public class ReplaceSpace {
    public String replaceSpace(String str){
        String newStr;
        if(str == null){
            return null;
        }

        StringBuffer strBuffer = new StringBuffer();
        for(int i = 0; i < str.length() ; i++){

            if(str.charAt(i) == ' '){
                strBuffer.append("%20");
            }else{
                strBuffer.append(String.valueOf(str.charAt(i)));
            }

        }
        newStr = strBuffer.toString();
        return newStr;
    }
}
